package mysql

import "gorm.io/gorm"

type Course struct {
	gorm.Model
	CourseName string  `gorm:"type:varchar(100);not null" json:"course_name"`
	StartTime  string  `gorm:"type:datetime;" json:"start_time"`
	Price      float64 `gorm:"type:decimal(10,2);" json:"price"`
}

func (c *Course) FindCourseByCourseName(course string) (*Course, error) {
	err := DB.Where("course_name=?", course).Find(&c).Error
	if err != nil {
		return nil, err
	}
	return c, nil
}
